package com.example.adminframework.constant;

/**
 * http返回码
 * <p>
 * <p>
 * 200: '响应成功',         # OK
 * 400: 'API请求错误',      # Bad Request(validate)
 * 401: '未经授权的API',    # Unauthorized(permission)
 * 403: '被禁止访问的API',   # Forbidden(session)
 * 404: '找不到请求的API',   # Not Found
 * 500: '服务器内部错误',    # Internal Server Error
 */
public enum HttpCode {
    /**
     * 响应成功
     */
    OK(200, "OK"),
    /**
     * API请求错误(验证)
     */
    BAD_REQUEST(400, "Bad Request"),
    /**
     * 未经授权的API(permission)
     */
    UNAUTHORIZED(401, "Unauthorized"),
    /**
     * 被禁止访问的的API(session)
     */
    FORBIDDEN(403, "Forbidden"),
    /**
     * 找不到请求的API
     */
    NOT_FOUND(404, "Not Found"),
    /**
     * 服务器内部错误
     */
    INTERNAL_SERVER_ERROR(500, "Internal Server Error");


    private Integer code;
    private String message;

    HttpCode() {
    }

    HttpCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public String toString() {
        return "HttpCode{" +
                "code=" + code +
                ", message='" + message + '\'' +
                '}';
    }
}
